package com.espirit.finance.core;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Table;

import com.espirit.EntityMapping;
import com.espirit.eap.annotation.ModelDisplayProperty;
import com.googlecode.cswish.model.Saas;

//@DomainModel
@Entity
@ModelDisplayProperty("name")
@Table(indexes={
		@Index(name="idx_name", columnNames={"name"} )},appliesTo = "saas_acctterm")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class AcctTerm extends EntityMapping implements Serializable, Saas{

	private static final long serialVersionUID = 6316146361465552121L;
	
	private Integer sid;
	public Integer getSid() {
		return sid;
	}

	public void setSid(Integer sid) {
		this.sid = sid;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}


	public Date getBeginDate() {
		return beginDate;
	}
	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}


	public Date getEndDate() {
		return endDate;
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}


	private String name;
	private Date beginDate;
	private Date endDate;
	
	@Transient
	public Integer getYear(){
		return Integer.valueOf(new SimpleDateFormat("yyyy").format(beginDate));
	}
	
	@Transient
	public Integer getMonth(){
		return Integer.valueOf(new SimpleDateFormat("MM").format(beginDate));
	}
	
}
